// *******************************************************************************************
// Figure C1: Industrial density (establishment employment over parcel size) and establishment
// *******************************************************************************************

// Writes the results as reg_montreal to $resultpath/figures/

set scheme s2color

use "$outpath/database_for_reg.dta", clear

xi: reghdfe Lnland_pwc Lnpopcma Lnareacma dist_min_NEW i.cat0 spacematep spacematep2 spacematep3 spacematep4 Lnemp i.hoffice i.exports NBdiffbusiness NBdiffnaics4 NBdiffproduct Lndist_maj_air Lndist_maj_sea Lndist_stat_freight Lndist_junction if samplep==1&year==2017&employment<=5, absorb(naics4d eruid) cluster(cmauid)
estimates store coef5

xi: reghdfe Lnland_pwc Lnpopcma Lnareacma dist_min_NEW i.cat0 spacematep spacematep2 spacematep3 spacematep4 Lnemp i.hoffice i.exports NBdiffbusiness NBdiffnaics4 NBdiffproduct Lndist_maj_air Lndist_maj_sea Lndist_stat_freight Lndist_junction if samplep==1&year==2017&employment>5&employment<=15, absorb(naics4d eruid) cluster(cmauid)
estimates store coef515

xi: reghdfe Lnland_pwc Lnpopcma Lnareacma dist_min_NEW i.cat0 spacematep spacematep2 spacematep3 spacematep4 Lnemp i.hoffice i.exports NBdiffbusiness NBdiffnaics4 NBdiffproduct Lndist_maj_air Lndist_maj_sea Lndist_stat_freight Lndist_junction if samplep==1&year==2017&employment>15&employment<=50, absorb(naics4d eruid) cluster(cmauid)
estimates store coef1550

xi: reghdfe Lnland_pwc Lnpopcma Lnareacma dist_min_NEW i.cat0 spacematep spacematep2 spacematep3 spacematep4 Lnemp i.hoffice i.exports NBdiffbusiness NBdiffnaics4 NBdiffproduct Lndist_maj_air Lndist_maj_sea Lndist_stat_freight Lndist_junction if samplep==1&year==2017&employment>50, absorb(naics4d eruid) cluster(cmauid)
estimates store coef50

coefplot (coef5, mcolor(black) ciopts(color(black) recast(rcap)) keep(Lnemp) rename(Lnemp="1-5 emp.")) (coef515, mcolor(black) ciopts(color(black) recast(rcap)) keep(Lnemp) rename(Lnemp="5-15 emp."))  (coef1550, mcolor(black) ciopts(color(black) recast(rcap)) keep(Lnemp) rename(Lnemp="15-50 emp.")) (coef50, mcolor(black) ciopts(color(black) recast(rcap)) keep(Lnemp) rename(Lnemp="50+ emp.")) , legend(off) xtitle("Coef. Ln Emp.") grid(none) graphregion(color(white)) bgcolor(white)
graph export "$resultpath/figures/coef_emp_size_parcel.pdf", replace
graph export "$resultpath/figures/coef_emp_size_parcel.eps", replace

coefplot (coef5, mcolor(black) ciopts(color(black) recast(rcap)) keep(Lnpopcma) rename(Lnpopcma="1-5 emp.")) (coef515, mcolor(black) ciopts(color(black) recast(rcap)) keep(Lnpopcma) rename(Lnpopcma="5-15 emp."))  (coef1550, mcolor(black) ciopts(color(black) recast(rcap)) keep(Lnpopcma) rename(Lnpopcma="15-50 emp.")) (coef50, mcolor(black) ciopts(color(black) recast(rcap)) keep(Lnpopcma) rename(Lnpopcma="50+ emp.")) , legend(off) xtitle("Coef. Ln CMA Pop.") grid(none) graphregion(color(white)) bgcolor(white)
graph export "$resultpath/figures/coef_cma_size_parcel.pdf", replace
graph export "$resultpath/figures/coef_cma_size_parcel.eps", replace

coefplot (coef5, mcolor(black) ciopts(color(black) recast(rcap)) keep(dist_min_NEW) rename(dist_min_NEW="1-5 emp.")) (coef515, mcolor(black) ciopts(color(black) recast(rcap)) keep(dist_min_NEW) rename(dist_min_NEW="5-15 emp."))  (coef1550, mcolor(black) ciopts(color(black) recast(rcap)) keep(dist_min_NEW) rename(dist_min_NEW="15-50 emp.")) (coef50, mcolor(black) ciopts(color(black) recast(rcap)) keep(dist_min_NEW) rename(dist_min_NEW="50+ emp.")) , legend(off) xtitle("Coef. Ln Dist. centre") grid(none) graphregion(color(white)) bgcolor(white)
graph export "$resultpath/figures/coef_dist_parcel.pdf", replace
graph export "$resultpath/figures/coef_dist_parcel.eps", replace

